﻿using System.Text;

namespace csharpcl
{
    public class GPUPlatform
    {
        public GPUDevice[] Devices { get; private set; }
        public ulong ID { get; private set; }
        public string Name { get; private set; }
        public GPUPlatform(ulong pid)
        {
            ID = pid;
        }

        public void Init()
        {
            Name = Introp.GetPlatformName(ID);
            var dids = Introp.GetDeviceIds(ID);
            if (dids == null || dids.Length == 0)
                Devices = new GPUDevice[0];
            else
            {
                Devices = new GPUDevice[dids.Length];
                for (int i = 0; i < dids.Length; i++)
                {
                    Devices[i] = new GPUDevice(ID, dids[i]);
                    Devices[i].Init();
                }
            }
        }
        public string ToStringEx()
        {
            var builder = new StringBuilder();
            builder.AppendLine("平台名称:  \t" + Name);
            builder.AppendLine("平台ID:   \t" + ID);
            builder.Append("设备数量: \t" + Devices.Length);
            return builder.ToString();
        }
    }
}